<template>
  <el-menu
    :ellipsis="false"
    class="route"
    text-color="#fff"
    background-color="transparent"
    mode="horizontal"
    menu-trigger="hover"
    style="max-width: 1300px"
  >
    <el-menu-item
      v-for="(item, index) in Routes"
      :key="index"
      :class="{ active: activeMenu === item.Name }"
      class="routeItem"
      @click="onSelectNav(item)"
    >
      <div class="title">
        <span>{{ item.Name }}</span>
      </div>
    </el-menu-item>
  </el-menu>
</template>

<script lang="ts" setup>
const route = useRoute();
const emit = defineEmits(['onSelectNav', 'saveCallBack']);

const Routes = [
  {
    path: '/qjxc',
    Name: '全景乡村'
  },
  {
    path: '/qjxc',
    Name: '乡村一张图'
  },
  {
    path: 'system',
    target: '_blank',
    Name: '后台管理'
  }
];
// 默认激活的菜单
const path = computed(() => {
  let path = route.path;
  return path;
});
const activeMenu = ref(Routes[0].Name);
const onSelectNav = (item) => {
  activeMenu.value = item.Name;
  emit('onSelectNav', item);
};
</script>

<style lang="scss" scoped>
.el-menu--horizontal.el-menu {
  border-bottom: none;
  display: flex;
  justify-content: flex-start;
}

.el-menu {
  width: 100%;
  height: 100%;
}

.routeItem {
  display: flex;
  height: 50px;
  justify-content: space-around;
  align-items: center;
  border-radius: 5px 0px 0px 5px;

  .title {
    flex: 1;
    font-size: 24px;
    height: 100%;
    // width: 100px;
    display: flex;
    align-items: center;
  }

  // &:hover {
  //   background: linear-gradient(-90deg, rgba(45, 203, 240, 0) 0%, rgba(45, 211, 250, 0.96) 99%);
  // }

  &.active {
    background: url('@/assets/common/xz.png') no-repeat 0 -4px / 100% 145%;
  }
}
</style>

<style lang="scss" setup>
:deep(.el-menu--horizontal) :deep(.el-menu) :deep(.el-menu-item) {
  height: 50px !important;
}

:deep(.el-menu--horizontal) :deep(.el-menu) :deep(.el-menu--popup) {
  padding: 0px !important;
}

:deep(.el-popper.is-pure) {
  background-color: #1f5f6e;

  div {
    ul {
      padding: 0px;
    }
  }
}
</style>
